package com.bsoft.gol.hbs.dao;

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import ctd.persistence.support.hibernate.HibernateSupportDelegateDAO;
import hcn.base.BaseActionRecord;

import java.util.List;

/**
 * 基础交互记录表
 */
public abstract class BaseActionRecordDAO extends HibernateSupportDelegateDAO<BaseActionRecord> {

    /**
     * 查询用户的互动记录业务之间列表
     *
     * @param userId       用户id
     * @param action       互动动作
     * @param businessType 业务类型
     * @return
     */
    @DAOMethod(sql = "SELECT DISTINCT businessId FROM BaseActionRecord WHERE businessType=:businessType AND action=:action AND userId=:userId")
    public abstract List<String> findBusinessIdList(@DAOParam("businessType") String businessType, @DAOParam("action") String action, @DAOParam("userId") String userId);

    /**
     * 根据索引查询一条数据
     */
    @DAOMethod(sql = "FROM BaseActionRecord WHERE businessId=:businessId AND businessType=:businessType AND action=:action AND userId=:userId")
    public abstract List<BaseActionRecord> findByBizKey(@DAOParam("businessId") String businessId,
                                                        @DAOParam("businessType") String businessType,
                                                        @DAOParam("action") String action,
                                                        @DAOParam("userId") String userId);

    /**
     * 删除对应的记录
     *
     * @param businessId   业务id
     * @param businessType 业务类型
     * @param action       互动动作
     * @param userId       用户id
     */
    @DAOMethod(sql = "DELETE FROM BaseActionRecord WHERE businessId=:businessId AND businessType=:businessType AND action=:action AND userId=:userId")
    public abstract void deleteByBizKey(@DAOParam("businessId") String businessId,
                                        @DAOParam("businessType") String businessType,
                                        @DAOParam("action") String action,
                                        @DAOParam("userId") String userId);

//    public BaseActionRecord queryByParam(BaseActionRecordQo qo) {
//        QoHibernateStatelessResultAction<BaseActionRecord, BaseActionRecordQo> action
//                = new QoHibernateStatelessResultAction<>(true, qo, HealthInfo.class);
//    }


}
